<template>

  <!-- 自定义对话框 -->
  <custom-dialog ref="customDialogRef" v-slot="{ formData }" :api-map="{ update: updateStatus }" header="修改状态"
    @request-success="handleDialogRequestSuccess">
    <t-form-item label="状态" name="status" :rules="[{ required: true, message: '请选择状态' }]">
      <t-select v-model:value="formData.status" :options="dictionaryStore.get('engineering_status')" placeholder="请选择状态"
        clearable filterable @clear="formData.status = null" />
    </t-form-item>
  </custom-dialog>
</template>

<script setup lang="ts">
import { MessagePlugin } from 'tdesign-vue-next';
import { PropType, ref, useTemplateRef } from 'vue';

import { updateStatus } from '@/api/project/engineering';
import { getAllSimpleUserlist } from '@/api/system/user';
import CustomDialog from '@/components/custom/dialog/index.vue';
import { useDictionaryStore } from '@/store';

// props
const props = defineProps({
  // 施工id
  id: {
    type: Number,
    required: true,
  },

});
// 字典仓库
const dictionaryStore = useDictionaryStore();
// emits
const emits = defineEmits(['requestSuccess']);

// 自定义对话框ref
const customDialogRef = useTemplateRef('customDialogRef');
// 处理打开对话框
const handleOpenChangeStatusDialog = (mode: 'create' | 'read' | 'update', params: Record<string, any>) => {
  customDialogRef.value.open(mode, params);
};
// 处理对话框请求成功
const handleDialogRequestSuccess = (result: Record<string, any>) => {
  emits('requestSuccess', result);
};

defineExpose({
  handleOpenChangeStatusDialog,
});
</script>
